package com.example.multithread;

import java.util.concurrent.*;

class MyCallable implements Callable<String> {

    String result = "";

    @Override
    public String call() throws Exception {
        for (int i = 0; i < 100; i++) {
            result += "Callable: Martinyong" + i;
        }
        System.out.println("=========================");
        return result;
    }
}
public class CallableTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable myCallable = new MyCallable();
        RunnableFuture<String> future = new FutureTask<>(myCallable);
        Thread thread = new Thread(future);
        thread.start();;
        System.out.println(future.get());
    }
}
